import BusinessConstant from '@/constant/BusinessConstant';
import request from '@/request';
import { ReportEntity } from '@/entities/ReportEntity';

const PREFIX = BusinessConstant.ROOT_SERVER + '/report';

export default class HouseReportApi {
  /**
   * 添加维修记录
   * @param data
   */
  static addReport(data: ReportEntity.IAddReportReq) {
    return request({
      method: 'POST',
      url: `${ PREFIX }`,
      data,
    });
  }

  /**
   * 通过租客id获取维修信息
   * @param tenantId
   */
  static getReportByTenantId(tenantId: number) {
    return request({
      method: 'GET',
      url: `${ PREFIX }/tenant?tenantId=${ tenantId }`
    });
  }

  /**
   * 通过房东id获取维修信息
   * @param tenantId
   */
  static getReportByLandlordId(landlordId: number) {
    return request({
      method: 'GET',
      url: `${ PREFIX }/landlord?landlordId=${ landlordId }`
    });
  }

  /**
   * 更新维修状态
   * @param reportId 维修id
   * @param status 状态
   */
  static updateReportStatus(reportId: number, status: number) {
    return request({
      method: 'PUT',
      url: PREFIX,
      data: {
        reportId,
        status,
      }
    });
  }
}